<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport"
          content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no"/>

    <meta name="description" content="描述">
    <meta name="keywords" content="关键词">
    <link rel="icon" href="">
    <link rel="shortcut icon" href="">
    <!--    <link rel="stylesheet" href="//at.alicdn.com/t/font_2052942_xzk2q3ix0w.css">-->
    <title>电梯采购网</title>
    <link rel="stylesheet" href="/web/public/css/public.css">
    <link rel="stylesheet" href="/web/public/css/header.css">
    <link rel="stylesheet" href="/web/public/css/footer.css">
    <link rel="stylesheet" href="/web/public/css/right.css">1

    <link rel="stylesheet" href="/web/public/css/list.css">
    <script src="/web/lib/jquery-1.12.4.min.js"></script>
    <script src="/web/public/public.js"></script>
    <script src="/web/lib/jquery.pagination.js"></script>
</head>
<body>
<div class="container">
    <!--这里引入header-->
    <include file="/web/html/header/header.htm" page-type="1"></include>
    <div id="main">
        <div class="left">
            <h2 class="position">
                <a href="###" target="_blank">首页</a> - <a href="###" target="_blank">热点Tag</a> - <span></span>
            </h2>

            <ul class="content-list">

            </ul>
            <div class="list-pagination"></div>
        </div>
        <div class="right">
            <!--            今日标讯-->
            <include file="/web/html/fragment/today-bid.htm"></include>
            <!--            大标推荐-->
            <include file="/web/html/fragment/recommend-bid.htm"></include>
            <include file="/web/html/fragment/right-ad.htm"></include>
            <!--            热搜榜-->
            <include file="/web/html/fragment/index-hot-search.htm"></include>
            <!--            精品店-->
            <include file="/web/html/fragment/index-boutique.htm"></include>
            <!--            评优评测-->
            <include file="/web/html/fragment/index-evaluating.htm"></include>
        </div>
    </div>
    <include file="/web/html/footer/footer.htm"></include>
</div>
<script>
    var tagId = utils.getQueryVariable('id');
    var tag = utils.getQueryVariable('tag');

    if (tag != null) {
        $(".position span").html(" -> " + tag);
    }

    $.ajax({
        url: ports.getTagListTdk,
        data: {
            keyword: tagId
        },
        success: function (res) {
            console.log('获取标签列表tdk', res);
            $("title").text(res.data.channelTitle + '-政府采购信息网' || '政府采购信息网');
            $("meta[name='keywords']").prop('content', res.data.channelKeyword || '');
            $("meta[name='description']").prop('content', res.data.channelDescriptions || '');
        }
    })

    function getTagList(pageNum, resetPage) {
        var pageSize = 10;
        $.ajax({
            url: ports.getTagList,
            data: {
                tag: tag,
                keyword: tagId,
                pageNum: pageNum,
                pageSize: pageSize
            },
            success: function (res) {
                console.log('获取标签列表', res);
                if (res.status == 200) {
                    var tagListHtml = '';
                    var tagList = res.data.list;
                    if (tagList && tagList.length) {
                        tagList.forEach(function (item) {
                            var keywordsListHtml = '';
                            if (item.articleKeywords && item.articleKeywords.length) {
                                item.articleKeywords.forEach(function (item1) {
                                    keywordsListHtml += '<a href=' + '/web/html/list/tags-list.html?id=' + item1.value + ' class="tag">' + item1.label + '</a>'
                                })
                            }

                            tagListHtml += '<li>\n' +
                                (item.articleImage ? '<div class="left"><a target="_blank" href=' + item.articleUrl + '><img src=' + item.articleImage + ' title=' + item.articleTitle + ' alt=' + item.articleTitle + '></a></div>' : '')
                                +
                                '                    <div class="right">\n' +
                                '                        <h3 class="title"><a target="_blank" href=' + item.articleUrl + '>' + item.articleTitle + '</a></h3>\n' +
                                '                        <p></p>' +
                                '                        <div class="info">\n' +
                                '                            <i class="iconfont icon-shijian"></i><span>' + item.createTime.substr(0, 10) + '</span>\n' +
                                '\n'
                                + keywordsListHtml +
                                '                        </div>\n' +
                                '                    </div>\n' +
                                '                </li>'
                        })
                    } else {
                        tagListHtml = '<li class="no-data">暂无数据</li>';
                        $('.list-pagination').remove();
                    }

                    $('ul.content-list').html(tagListHtml);
                    if (resetPage) {
                        $('.list-pagination').pagination({
                            prevContent: '< 上一页',
                            nextContent: '下一页 >',
                            totalData: res.data.total || 1,
                            showData: pageSize,
                            coping: true,
                            callback: function (api) {
                                console.log(api.getCurrent());
                                var current = api.getCurrent();
                                document.body.scrollTop = 0;
                                document.documentElement.scrollTop = 0;
                                getTagList(current, false);
                            }
                        });
                    }
                }
            }
        });
    }

    getTagList(1, true);

</script>
</body>
</html>